// src/services/useFilterActions.js
// 封装列表页面的筛选
import {ref} from "vue";

export function useFilterActions(initialFields = { name: '', component: '' }, { onFilter = () => {}, onReset = () => {} } = {}) {
  const filter = ref({ ...initialFields })

  function handleFilter() {
    filter.value = { ...filter.value }
    onFilter({ ...filter.value })
  }

  function resetFilter() {
    filter.value = { ...initialFields }
    onReset()
  }

  return {
    filter,
    handleFilter,
    resetFilter
  }
}